package org.example.minebackend.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;
import org.example.minebackend.pojo.Invitation;
import org.example.minebackend.pojo.Recipe;
import org.example.minebackend.pojo.User;
import org.example.minebackend.pojo.dto.PersonDTO;

import java.util.List;

@Mapper
public interface PersonCenterMapper {
    @Select("select recipeId from recipesofcollection where userId=#{userId}")
    List<Integer> getCollectionRecipeIdByUserId(Integer userId);

    @Select("select invitationId from invitationofcollection where userId=#{userId}")
    List<Integer> getCollectionInvitationByUserId(Integer userId);

    List<Recipe> getRecipeById(List<Integer> recipeId);

    Page<Invitation> getInvitationsById(List<Integer> invitationId);

    @Select("select * from user where id=#{id}")
    User getMessage(Integer id);

    @Update("update user set username=#{username}, password=#{password}, image=#{image}")
    int updatePerson(User user);

    @Select("select * from invitation where writerId=#{userId}")
    List<Invitation> getInvitationsByUserId(Integer userId);

    @Delete("delete from invitationcomment where invitationId=#{invitationId}")
    int deleteInvitationComment(Integer invitationId);

    @Delete("delete from invitationofcollection where invitationId=#{invitationId}")
    int deleteCollectionInvitation(Integer invitationId);

    @Delete("delete from invitation where id=#{id}")
    int deleteInvitationById(Integer id);
}
